package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.SurveyDepotResult;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SurveyDepotResultDAO{
	
	@SQL("SELECT a.*,b.name as surveyName FROM SurveyDepotResult a left join Survey b on a.surveyId=b.id and b.type=1 WHERE a.deleteFlag=1 #if(:t.descs!=''){AND a.descs like '%##(:t.descs)%' } ORDER BY a.updateAt DESC LIMIT :t.start,:t.length ")
    List<SurveyDepotResult> query(@SQLParam("t") SurveyDepotResult surveyDepotResult);
		
	@SQL("SELECT count(1) FROM SurveyDepotResult WHERE deleteFlag=1 #if(:t.descs!=''){AND descs like '%##(:t.descs)%' } ")
    int querySize(@SQLParam("t") SurveyDepotResult surveyDepotResult);
    
    @SQL("select * from SurveyDepotResult where id=:1 ")
    SurveyDepotResult queryById(int id);
    
    @SQL("INSERT INTO SurveyDepotResult (surveyId,answersIds,descs,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.surveyId,:t.answersIds,:t.descs,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") SurveyDepotResult surveyDepotResult);
	
	@SQL("UPDATE SurveyDepotResult SET surveyId=:t.surveyId,answersIds=:t.answersIds,descs=:t.descs,updateUser=:t.updateUser,updateAt=now() WHERE id=:t.id")
    void update(@SQLParam("t") SurveyDepotResult surveyDepotResult);
    
    @SQL("UPDATE SurveyDepotResult SET deleteFlag=0 WHERE id=:1 ")
    void deleteById(int id);
}